<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.thymeleaf.org/thymeleaf-extras-shiro">
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>
    <script th:src="@{/js/jquery-2.2.3.min.js}" charset="utf-8"></script>
    <link rel="shortcut icon" href="../resources/favicon.ico" th:href="@{/static/favicon.ico}"/>

</head>
<body>



<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="shou">受理</a>
    <a class="layui-btn layui-btn-xs" lay-event="tui">退回</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="wan">完工</a>
</script>


<table class="layui-hide" id="test" lay-filter="test"></table>

<script>
    //表单
    layui.use(["table", "form"], function () {
        var table = layui.table;
        var form = layui.form;
        ptable= function () {
            table.render({
                elem: '#test'
                , url: '/support/waitchartlistdata'
                , toolbar: '#toolbarDemo'
                , title: '用户数据表'
                , limit: 10
                , page: true
                , cols: [
                    [
                        {type: 'checkbox', fixed: 'left'}
                        , {
                        field: 'id',
                        title: 'ID',
                        width: 80,
                        fixed: 'left',
                        unresize: true,
                        sort: true,
                        totalRowText: '合计'
                    }

                        , {field: 'title', title: '标题', width: 200}
                        , {field: 'publishtime', title: '提交时间', width: 200}
                        , {field: 'author', title: '提交者', width: 100}
                        , {field: 'urgent', title: '紧急程度', width: 100}
                        , {field: 'status', title: '工单状态', width: 150}
                        , {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 200}
                    ]
                ]

            });
        }
        ptable();



        //监听工具条
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            if (obj.event === 'wan') {
                var id = data.id;
                $.ajax({
                    url: '/support/changechartliststatuswan',
                    type: "POST",
                    data: {"id": id},
                    success: function () {
                        ptable();

                    }
                });

            }
            if (obj.event === 'shou') {
                var id = data.id;
                $.ajax({
                    url: '/support/changechartliststatusshou',
                    type: "POST",
                    data: {"id": id},
                    success: function () {
                        ptable();

                    }
                });

            }
            else if (obj.event === 'tui') {
                var id = data.id;
                $.ajax({
                    url: '/support/changechartliststatustui',
                    type: "POST",
                    data: {"id": id},
                    success: function () {
                        ptable();

                    }
                });

            }
        });








    });


</script>
</body>
</html>